package demo.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import demo.bean.ValidBean;

@RestController
@RequestMapping("/valid")
public class ValidController {

	@RequestMapping("test1")
	@ResponseBody
	public Map<String,Object> test1(@Validated ValidBean bean, BindingResult bindingResult) {
		Map<String,Object> map = new HashMap<>();
		map.put("data", bean);
		map.put("errors", bindingResult.getAllErrors());
		return map;
	}
	
}